﻿using Abp.Authorization;
using Abp.Localization;
using Abp.MultiTenancy;

namespace shenghua.Authorization
{
    public class shenghuaAuthorizationProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            // 面向管理员的权限
            var administration = context.CreatePermission(PermissionNames.Administration, L("管理员"));
            administration.CreateChildPermission(PermissionNames.Pages_Users, L("管理员管理"));
            administration.CreateChildPermission(PermissionNames.Pages_Roles, L("角色管理"));
            //context.CreatePermission(PermissionNames.Pages_Tenants, L("租户管理"), multiTenancySides: MultiTenancySides.Host);

            administration.CreateChildPermission(PermissionNames.CommodityManagement, L("商品管理"));
            administration.CreateChildPermission(PermissionNames.CommodityClassManagement, L("商品类别管理"));
            administration.CreateChildPermission(PermissionNames.CommodityWareManagement, L("商品库管理"));
            administration.CreateChildPermission(PermissionNames.CommodityShoppingOptionManagement, L("购物选项管理"));
            administration.CreateChildPermission(PermissionNames.MemberManagement, L("会员管理"));
            administration.CreateChildPermission(PermissionNames.OrderManagement, L("订单管理"));
            administration.CreateChildPermission(PermissionNames.WebsiteInfoManagement, L("网站信息管理"));
            administration.CreateChildPermission(PermissionNames.OrderEvaluateManagement, L("订单评价管理"));
            administration.CreateChildPermission(PermissionNames.MemberFormItemManagement, L("会员表单管理"));
            administration.CreateChildPermission(PermissionNames.CommodityGuaranteeManagement, L("商品保证管理"));
            administration.CreateChildPermission(PermissionNames.CouponManagement, L("优惠券管理"));
            administration.CreateChildPermission(PermissionNames.SalesPromotionManagement, L("限时活动管理"));
            administration.CreateChildPermission(PermissionNames.ResourceManagement, L("资源库管理"));
            administration.CreateChildPermission(PermissionNames.ArticleManagement, L("文章管理"));
            administration.CreateChildPermission(PermissionNames.MallGeneralManagement, L("商城常规设置"));
            administration.CreateChildPermission(PermissionNames.ShipManagement, L("配送管理"));
            administration.CreateChildPermission(PermissionNames.XPManagement, L("积分管理"));
            administration.CreateChildPermission(PermissionNames.PersonalProfile, L("个人中心"));
            administration.CreateChildPermission(PermissionNames.ChangePassword, L("修改密码"));
            administration.CreateChildPermission(PermissionNames.ModifyProfile, L("个人中心设置"));
            administration.CreateChildPermission(PermissionNames.PaymentManagement, L("支付设置"));
            administration.CreateChildPermission(PermissionNames.FeedbackManagement, L("留言管理"));

            // 面向用户的权限
            var member = context.CreatePermission("Member", L("会员"));
            //member.CreateChildPermission("Member.UserManagement.CreateUser", L("创建会员"));
        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, shenghuaConsts.LocalizationSourceName);
        }
    }
}
